package com.zzyl.nursing.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zzyl.common.utils.DateUtils;
import com.zzyl.nursing.dto.NursingLevelDto;
import com.zzyl.nursing.vo.NursingLevelVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zzyl.nursing.mapper.NursingLevelMapper;
import com.zzyl.nursing.domain.NursingLevel;
import com.zzyl.nursing.service.INursingLevelService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.Arrays;

/**
 * 护理等级Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-31
 */
@Service
public class NursingLevelServiceImpl extends ServiceImpl<NursingLevelMapper, NursingLevel> implements INursingLevelService
{
    @Autowired
    private NursingLevelMapper nursingLevelMapper;

    /**
     * 查询护理等级
     * 
     * @param id 护理等级主键
     * @return 护理等级
     */
    @Override
    public NursingLevelDto selectNursingLevelById(Integer id)
    {
        NursingLevel nursingLevel = getById(id);
        NursingLevelDto dto = new NursingLevelDto();
        BeanUtils.copyProperties(nursingLevel, dto);
        return dto;
    }

    /**
     * 查询护理等级列表
     * 
     * @param nursingLevel 护理等级
     * @return 护理等级
     */
    @Override
    public List<NursingLevel> selectNursingLevelList(NursingLevel nursingLevel)
    {
        return nursingLevelMapper.selectNursingLevelList(nursingLevel);
    }

    /**
     * 新增护理等级
     * 
     * @param dto 护理等级
     * @return 结果
     */
    @Override
    public int insertNursingLevel(NursingLevelDto dto)
    {
        NursingLevel nursingLevel = new NursingLevel();
        BeanUtils.copyProperties(dto, nursingLevel);
        return save(nursingLevel) ? 1 : 0;
    }

    /**
     * 修改护理等级
     * 
     * @param dto 护理等级
     * @return 结果
     */
    @Override
    public int updateNursingLevel(NursingLevelDto dto)
    {
        NursingLevel nursingLevel = new NursingLevel();
        BeanUtils.copyProperties(dto, nursingLevel);
        return updateById(nursingLevel) ? 1 : 0;
    }

    /**
     * 删除护理等级信息
     * 
     * @param id 护理等级主键
     * @return 结果
     */
    @Override
    public int deleteNursingLevelById(Integer id)
    {
        return removeById(id) ? 1 : 0;
    }

    @Override
    public List<NursingLevel> selectAll() {
        LambdaQueryWrapper<NursingLevel> qw = new LambdaQueryWrapper<>();
        qw.eq(NursingLevel::getStatus,1);
        return nursingLevelMapper.selectList(qw);
    }
}
